Skip to main content
Version: 6.2.2

deserializeTransaction() <src>

Deserialize a transaction, convert raw data hex into an object.

Usage

utils.deserializeTx.deserializeTransaction(type, rawDataHex)

Parameters

ArgumentDescriptionType
typeThe transaction type.string
typeThe raw data hex of a transaction.string

Note:

  1. In TronWeb v6.0.2, we used to deserialize a triggerSmartContract type transaction by DTriggerSmartContract. But we give a unified API to deserialize transactions with any type in this version. And DTriggerSmartContract no longer exists.
  2. In TronWeb v6.1.0, we refactored the related code into a new file. As a result, the utils module has been updated to deserializeTx. And DeserializeTransaction has been renamed to deserializeTransaction, with the initial "D" now lowercase.

Supported type

  • TriggerSmartContract
  • FreezeBalanceV2Contract
  • UnfreezeBalanceV2Contract
  • CancelAllUnfreezeV2Contract
  • DelegateResourceContract
  • UnDelegateResourceContract
  • WithdrawExpireUnfreezeContract
  • TransferContract
  • WithdrawBalanceContract
  • WitnessCreateContract
  • TransferAssetContract
  • ParticipateAssetIssueContract
  • AssetIssueContract
  • UpdateAssetContract

Return

Object - An object with the transaction data.

Example

import { TronWeb, utils } from 'tronweb';

const tronWeb = new TronWeb({
fullHost: 'https://api.nileex.io',
privateKey: 'your private key',
});
const contractAddress = 'TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf'; // nile usdt address
const account = await tronWeb.createAccount();
const account2 = await tronWeb.createAccount();
const tx = (await tronWeb.transactionBuilder.triggerSmartContract(
contractAddress,
'transfer(address,uint256)',
{
txLocal: true,
tokenId: '1000008',
tokenValue: 100,
feeLimit: 100 * (10 ** 6),
},
[
{ type: "address", value: account2.address.base58 },
{ type: "uint256", value: 100000000 }
],
account.address.base58,
)).transaction;
const dResult = utils.deserializeTx.deserializeTransaction('TriggerSmartContract', tx.raw_data_hex);